import Router from 'koa-router';
import proxyService from '../../common/proxyService';
import {
  loadCorpDeptTreeAgent,
  saveCorpDeptAgent,
  deleteCorpDeptAgent,
  updateDeptOrderAgent,
  getEmployeeListByPageAgent,
  saveEmployeeDataAgent,
  checkEeNumAgent,
  getEmployeeEditByEeIdAgent,
  updateEmployeeDataAgent,
  updateEmployeeAuthAgent,
  updateInviteEmployUnBindAgent,
  updateEmployeeListStatusAgent,
  queryAgentRoleListAgent,
  getSeatUnassignedTotalAgent,
  updateInviteEmployeeAgent,
  updateSetTopEmployeeAgent,
  updateCancelTopEmployeeAgent,
  queryEmployeeRoleListAgent,
  getInviteEmployInfoAgent,
  updateInviteEmployeePageAgent,
} from '../../api/agent';

const router = new Router();

// 获取部门树
router.post('/loadCorpDeptTree', async ctx => {
  console.log(ctx.requestParams);
  const response = await proxyService.postProxy(ctx, loadCorpDeptTreeAgent);
  return (ctx.body = response);
});

router.post('/saveCorpDept', async ctx => {
  const response = await proxyService.postProxy(ctx, saveCorpDeptAgent);
  return (ctx.body = response);
});

router.post('/deleteCorpDept', async ctx => {
  const response = await proxyService.postProxy(ctx, deleteCorpDeptAgent);
  return (ctx.body = response);
});

router.post('/updateDeptOrder', async ctx => {
  const response = await proxyService.postProxy(ctx, updateDeptOrderAgent);
  return (ctx.body = response);
});

//
router.post('/getEmployeeListByPage', async ctx => {
  const response = await proxyService.postProxy(ctx, getEmployeeListByPageAgent);
  return (ctx.body = response);
});

//
router.post('/saveEmployeeData', async ctx => {
  let response = await proxyService.postProxy(ctx, saveEmployeeDataAgent);
  return (ctx.body = response);
});

// 修改部门
router.post('/checkEeNum', async ctx => {
  const response = await proxyService.postProxy(ctx, checkEeNumAgent);
  return (ctx.body = response);
});

//
router.post('/getEmployeeEditByEeId', async ctx => {
  const response = await proxyService.postProxy(ctx, getEmployeeEditByEeIdAgent);
  return (ctx.body = response);
});

//
router.post('/updateEmployeeData', async ctx => {
  const response = await proxyService.postProxy(ctx, updateEmployeeDataAgent);
  return (ctx.body = response);
});

// 添加用户
router.post('/updateEmployeeAuth', async ctx => {
  const response = await proxyService.postProxy(ctx, updateEmployeeAuthAgent);
  return (ctx.body = response);
});

// 修改用户
router.post('/updateInviteEmployUnBind', async ctx => {
  const response = await proxyService.postProxy(ctx, updateInviteEmployUnBindAgent);
  return (ctx.body = response);
});

router.post('/updateEmployeeListStatus', async ctx => {
  const response = await proxyService.postProxy(ctx, updateEmployeeListStatusAgent);
  return (ctx.body = response);
});

router.post('/queryAgentRoleList', async ctx => {
  const response = await proxyService.postProxy(ctx, queryAgentRoleListAgent);
  return (ctx.body = response);
});
router.post('/getSeatUnassignedTotal', async ctx => {
  const response = await proxyService.postProxy(ctx, getSeatUnassignedTotalAgent);
  return (ctx.body = response);
});
router.post('/updateInviteEmployee', async ctx => {
  const response = await proxyService.postProxy(ctx, updateInviteEmployeeAgent);
  return (ctx.body = response);
});
router.post('/updateSetTopEmployee', async ctx => {
  const response = await proxyService.postProxy(ctx, updateSetTopEmployeeAgent);
  return (ctx.body = response);
});
router.post('/updateCancelTopEmployee', async ctx => {
  const response = await proxyService.postProxy(ctx, updateCancelTopEmployeeAgent);
  return (ctx.body = response);
});
router.post('/queryEmployeeRoleList', async ctx => {
  const response = await proxyService.postProxy(ctx, queryEmployeeRoleListAgent);
  return (ctx.body = response);
});
router.post('/getInviteEmployInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getInviteEmployInfoAgent);
  return (ctx.body = response);
});
router.post('/updateInviteEmployeePage', async ctx => {
  const response = await proxyService.postProxy(ctx, updateInviteEmployeePageAgent);
  return (ctx.body = response);
});

export default router;
